﻿<%@ Page Language="C#" MasterPageFile="~/ExampleMaster.Master" AutoEventWireup="true"
    CodeBehind="FilteredSelect.aspx.cs" Inherits="Web.Samples.FilteredSelect" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleZone" runat="server">
    Filtered Select
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="IntroTextZone" runat="server">
    Using the where keyword within our queries we can filter collections down into subsets
    of data based on a condition or set of conditions
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="QueryExpressZone" runat="server">
    <pre class="code">            <span style="color: rgb(0,0,255)">var</span> query = (<span
        style="color: rgb(0,0,255)">from</span> o <span style="color: rgb(0,0,255)">in</span> <span
            style="color: rgb(43,145,175)">Product</span>.GetProducts()
                         <span style="color: rgb(0,0,255)">where</span> o.Name.StartsWith(<span style="color: rgb(163,21,21)">"A"</span>)
                         <span style="color: rgb(0,0,255)">select</span> o.Name).Take(15);

            <span style="color: rgb(0,0,255)">foreach</span> (<span style="color: rgb(0,0,255)">string</span> s <span
                style="color: rgb(0,0,255)">in</span> query)
                <span style="color: rgb(0,0,255)">this</span>.litQueryResults.Text += s + <span style="color: rgb(163,21,21)">"&lt;br
                    /&gt;\n"</span>;</pre>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="QueryResultsZone" runat="server">
    <asp:Literal ID="litQueryResults" runat="server" />
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ImperativeZone" runat="server">
    <pre class="code">&nbsp;</pre>
    <pre class="code">            <span style="color: rgb(0,0,255)">var</span> query = <span
        style="color: rgb(43,145,175)">Product</span>.GetProducts().Where(p =&gt; p.Name.StartsWith(<span
            style="color: rgb(163,21,21)">"A"</span>)).Select(p =&gt; p);

            <span style="color: rgb(0,0,255)">foreach</span> (<span style="color: rgb(0,0,255)">string</span> s <span
                style="color: rgb(0,0,255)">in</span> query)
                <span style="color: rgb(0,0,255)">this</span>.litImperativeResults.Text += s + <span
                    style="color: rgb(163,21,21)">"&lt;br /&gt;\n"</span>;</pre>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="ImperativeResultsZone" runat="server">
    <asp:Literal ID="litImperativeResults" runat="server" />
</asp:Content>
